package me.zk.practice1.hw;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class HWBJ03 {
    public static List<Integer> list = new ArrayList<>();
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int m = scanner.nextInt();
        getCount(m,0);
        Collections.sort(list);
        System.out.println(list.get(0));

    }

    public static void getCount(int m ,int count) {
        if (m == 1) {
            list.add(count);
        } else if(m % 2 == 0) {
            count++;
            getCount( m/2,count);
        } else {
            count++;
            getCount(m+1,count);
            getCount(m-1,count);
        }
    }
}
